<template>
	<view class="activityPaid" :style="[{paddingTop:statusBar+ 'px'}]">
		<view class="status" :style="[{height:statusBar+ 'px'}]" ></view>
		<view class="navigation" :style="[{top:(statusBar-2)+ 'px'}]">
			<image src="/static/images/back.png" class="back" @click="payBck()" mode=""></image>
			<view class="navigation-title"></view>
		</view>
		<view class="navigation-position"></view>
		<view class="activity-paid-content">
			<view class="activity-paid-state-content">
				<image src="/static/images/success.png" class="pay-success-icon" mode=""></image>
				<view class="pay-state-text">支付成功</view>
				<block v-if="isExcessReturn">
					<view class="pay-state-text-tips">请在活动列表“待处理中申请超额返或申请发货”</view>
				</block>
				<view class="paid-complete-operation">
					<view class="apply-again-sell backPrev" @click="payBck()">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	/* function getRequestParams() {
			let url = location.href;
			let requestParams = {};
			if (url.indexOf('?') !== -1) {
				let str = url.substr(url.indexOf('?') + 1);
				let strs = str.split('&');
				for (let i = 0; i < strs.length; i++) {
					requestParams[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
				}
			}
			return requestParams;
	}
	let params = getRequestParams();
	let token = params['token'];
	let status_bar =  params['status_bar'];
	let source = 'wap'
	if(token!=undefined){
		uni.setStorage({
		    key: 'token',
		    data: token
		})
		source = 'app'
	}
	if(status_bar!=undefined){
		uni.setStorage({
		    key: 'status_bar',
		    data: status_bar
		})
	} */
	import store from "store"
	import {mapGetters,mapMutations,mapActions} from 'vuex'
	export default {
		store,
		computed:{
			...mapGetters([
				'user',
				'statusBar'
			])
		},
		data(){
			return {
					source:source,
					isExcessReturn:false,
					records:[],
					needGoldbeans:null,
					price:null,
					isSingle:true,
					isBatch:false
			}
		},
		methods:{
			...mapMutations([
				'setUser',
				'setStatusBar'
			]),
			back(){
				if(this.source == 'wap'){
					uni.navigateBack()
				}else{
					// window.flutter_inappwebview.callHandler('back_to_app', '')
					backToApp.postMessage('back');
				}
			},
			payBck(){
				var pages= getCurrentPages()
				var prevPage = pages[pages.length-2]
				prevPage.$vm.backEvent()
				uni.navigateBack()
			},
			goActivitySellConfirm(){
				uni.redirectTo({
					url:'/packs/pages/activity/activitySellConfirm?records=' + encodeURIComponent(JSON.stringify(this.records)) + '&needGoldbeans=' + this.needGoldbeans + '&isExReturn=' + this. isExcessReturn + '&price=' + this.price
				})
			},
			goActivityExcessReturnConfirm(){
				uni.redirectTo({
					url:'/packs/pages/activity/activitySellConfirm?records=' + encodeURIComponent(JSON.stringify(this.records)) + '&needGoldbeans=' + this.needGoldbeans + '&isExReturn=' + this. isExcessReturn + '&price=' + this.price
				})
			},
			takeGoods(){
				uni.navigateBack({})
			}
		},
		async onShow(){
			if(status_bar!=undefined){
				this.setStatusBar(status_bar)
			}
		},
		onLoad(options) {
			if(options.isExReturn){
				this.isExcessReturn = JSON.parse(options.isExReturn) 
			}
			if(options.isBatch){
				this.isBatch = JSON.parse(options.isBatch)
			}
			this.records = JSON.parse(decodeURIComponent(options.records))
			this.needGoldbeans = options.needGoldbeans
			this.price = options.price
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background: #F6F6F6;
	}
	.status {
		width: 100%;
		position: fixed;
		top: 0;
		z-index: 99;
		background: #F6F6F6;
	}
	.navigation{
		width: 100%;
		height: 100rpx;
		background: #F6F6F6;
		display: flex;
		align-items: center;
		justify-content: center;
		position: fixed;
		left:0;
		top:0;
		z-index:999;
	}
	.navigation-position{
		width: 100%;
		height: 100rpx;
		background: rgba(0,0,0,0);
	}
	.back{
		display: block;
		width: 48rpx;
		height: 48rpx;
		position: absolute;
		top: 26rpx;
		left:32rpx;
	}
	.navigation-title{
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}
	.activity-paid-state-content{
		width: 686rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		margin: 50rpx auto;
		padding: 64rpx 0;
	}
	.pay-success-icon{
		display: block;
		width: 96rpx;
		height: 96rpx;
		margin:0 auto;
	}
	.pay-state-text{
		font-size: 36rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		line-height: 40rpx;
		text-align: center;
		margin-top: 24rpx;
	}
	.pay-state-text-tips1{
		margin-top: 24rpx;
	}
	.pay-state-text-tips{
		font-size: 28rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 40rpx;
		text-align: center;
		margin-top: 24rpx;
		margin-bottom: 8rpx;
	}
	.paid-complete-operation{
		display: flex;
		justify-content: center;
		margin-top: 80rpx;
		>view{
			width: 272rpx;
			height: 84rpx;
			border-radius: 48rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			font-family: PingFangSC-Semibold, PingFang SC;
			font-weight: 600;
		}
		.goods-back-home{
			border: 2rpx solid #FF6011;
			color: #FF9500;
			width: 270rpx;
			height: 82rpx;
			
		}
		.apply-excess-return,.apply-again-sell{
			background: #FF9500;
			color: #FFFFFF;
			margin-left: 32rpx;
		}
		.backPrev{
			margin-left: 0;
		}
	}
	
</style>